/***********************************************************/
/* Name: Stephen Wiens
/* Student No.: 00324854
/* Course: CPSC4559
/* SB Skype
* Reason: Start up screen for program - New user or existing user log in
/***********************************************************/

package Client;
import SBLib.User;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

/**
 *
 * @author Jimawuppy
 */
public class SBFrame extends javax.swing.JFrame {
static boolean exisiting = false;
static ObjectOutputStream outToServer;
static ObjectInputStream inFromServer;
static Socket clientSocket;
static User temp = new User(null,null);
    /** Creates new form SBFrame */
    public SBFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        NewUserButton = new javax.swing.JButton();
        ExisitingUserbutton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(0, 153, 255));

        NewUserButton.setText("New User");
        NewUserButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NewUserButtonActionPerformed(evt);
            }
        });

        ExisitingUserbutton.setText("Log in");
        ExisitingUserbutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExisitingUserbuttonActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("SB Drop Box");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ExisitingUserbutton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                    .addComponent(NewUserButton, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE))
                .addGap(40, 40, 40))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 116, Short.MAX_VALUE)
                .addComponent(NewUserButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ExisitingUserbutton)
                .addGap(17, 17, 17))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
//New User button has been pressed, brings through the current user, the output and input to the server
    private void NewUserButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewUserButtonActionPerformed
            NewUserForm.main(temp,outToServer,inFromServer,clientSocket);
    }//GEN-LAST:event_NewUserButtonActionPerformed
//Log in button has been pressed, bring through the current user, the output and input to the server
    private void ExisitingUserbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExisitingUserbuttonActionPerformed
            ExisitingUserForm.main(temp,outToServer,inFromServer,this,clientSocket);
    }//GEN-LAST:event_ExisitingUserbuttonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(final User temp1,final ObjectOutputStream outToServer1,final ObjectInputStream inFromServer1,final Socket clientSocket1) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                temp = temp1;
                outToServer=outToServer1;
                inFromServer=inFromServer1;
                new SBFrame().setVisible(true);   
                clientSocket = clientSocket1;
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ExisitingUserbutton;
    private javax.swing.JButton NewUserButton;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables

}
